/*
 * @Author: xuetao 3168581151@qq.com
 * @Date: 2025-03-05
 * @LastEditors: xuetao 3168581151@qq.com
 * @LastEditTime: 2025-03-13
 * @Description: 
 */
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:flutter/material.dart' show GlobalKey, NavigatorState;

import 'mobile_notify.dart' show MobileNotify;
import 'web_notify.dart' show WebNotify;
import 'notify_enum.dart';

/// 统一通知接口（跨平台适配）
class NotifyHelper {
  static bool _isInitialized = false;

  /// 初始化通知服务
  static Future<void> initialize(GlobalKey<NavigatorState> navigatorKey) async {
    if (_isInitialized) return;
    if (kIsWeb) {
      WebNotify.initialize(navigatorKey);
    } else {
      MobileNotify.initialize();
    }

    _isInitialized = true;
  }

  /// 显示通知（统一入口）
  static Future<void> notify({
    required String title,
    required String content,
    NotificationType type = NotificationType.system,
    String? targetRoute,
    String? iconUrl,
  }) async {
    if (kIsWeb) {
      WebNotify.show(
        title: title,
        content: content,
        targetRoute: targetRoute,
        iconUrl: iconUrl,
        type: type,
      );
    } else {
      MobileNotify.show(
        title: title,
        content: content,
        type: type,
        targetRoute: targetRoute,
      );
    }
  }
}
